package com.canbot.u05.view;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.canbot.u05.R;

/**
 * Created by lrh on 2017/3/2.
 */

public class SellModePropagandaDialog extends Dialog implements View.OnClickListener {

        public SellModePropagandaDialog(Context context, int id) {
                super(context, R.style.MyDialogStyle);
                setmenuDialog(id);
        }

        private void setmenuDialog(int id) {
                switch (id) {
                        case R.id.btn_delet:
                                View viewdel = LayoutInflater.from(getContext()).inflate(R.layout.sell_menu_dialog_del, null);
                                super.setContentView(viewdel);
                                Button btn_cal = (Button) viewdel.findViewById(R.id.btn_dialog_del_left);
                                Button btn_nor = (Button) viewdel.findViewById(R.id.btn_dialog_del_right);
                                btn_cal.setOnClickListener(this);
                                btn_nor.setOnClickListener(this);
                                break;
                        case R.id.btn_name:
                                View viewname = LayoutInflater.from(getContext()).inflate(R.layout.sell_menu_dialog_rename, null);
                                super.setContentView(viewname);
                                Button btn_rename_cal = (Button) viewname.findViewById(R.id.btn_dialogleft);
                                Button btn_rename_nor = (Button) viewname.findViewById(R.id.btn_dialogright);
                                btn_rename_cal.setOnClickListener(this);
                                btn_rename_nor.setOnClickListener(this);
                                break;

                }

//        super.setContentView(view);
        }

        public interface ModeDialogOclickListner {

                void onClick(int id);
        }

        public String getEtName() {
                EditText et = (EditText) findViewById(R.id.dialog_rename_et);
                return et.getText().toString().trim();
        }

        ModeDialogOclickListner listner;

        public void setListner(ModeDialogOclickListner listner) {
                this.listner = listner;
        }

        @Override
        public void onClick(View view) {
//                dismiss();
                if (listner != null) {
                        listner.onClick(view.getId());
                }
        }
}
